//
//  UserAccountModel.swift
//  weibo
//
//  Created by 孙新 on 16/4/19.
//  Copyright © 2016年 孙新. All rights reserved.
//

import UIKit

class UserAccountModel: NSObject,NSCoding {
    
    // 将获取到的数据字典形式赋值为模型的属性
   
    var access_token : String?
    var expires_in : Int = 0
    var remind_in : String?
    var uid : String?
    //用户名
    var name : String?
    //用户头像图片
    var avatar_large : String?
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    //归档
    func encodeWithCoder(enCoder: NSCoder) {
        enCoder.encodeObject(uid, forKey: "uid")
        enCoder.encodeInteger(expires_in, forKey: "expires_in")
        enCoder.encodeObject(remind_in, forKey: "remind_in")
        enCoder.encodeObject(access_token, forKey: "access_token")
        enCoder.encodeObject(avatar_large, forKey: "avatar_larg")
        enCoder.encodeObject(name, forKey: "name")
    }
    //解档
    required init?(coder Decoder: NSCoder) {
        uid = Decoder.decodeObjectForKey("uid") as? String
        expires_in = Decoder.decodeIntegerForKey("expires_in")
        remind_in = Decoder.decodeObjectForKey("remind_in") as? String
        access_token = Decoder.decodeObjectForKey("access_token") as? String
        avatar_large = Decoder.decodeObjectForKey("avatar_large") as? String
        name = Decoder.decodeObjectForKey("name") as? String
    }

}
